package com.liukai.todo_android.common.base;

import android.content.Context;
import android.os.Bundle;
import android.view.WindowManager;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @author ：liukai
 * @date ：Created in 2021/8/8 2:22 下午
 * @description：自定义Activity的基类
 * @modified By：
 * @version: $
 */
public abstract class BaseActivity extends AppCompatActivity {

    private Unbinder mBind;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        mBind = ButterKnife.bind(this);
        initData(this);
        initView();
        initListener();
    }

    /**
     * 获取布局Layout的Id
     *
     * @return
     */
    protected abstract int getLayoutId();

    /**
     * 初始化数据
     */
    protected abstract void initData(Context context);

    /**
     * 初始化组件
     */
    protected abstract void initView();


    /**
     * 初始化监听器
     */
    protected abstract void initListener();


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mBind != null) {
            mBind = null;
        }
        release();
    }

    /**
     * 销毁Activity释放资源
     */
    protected void release() {

    }

}
